package grabbitmq

import "wzgames/pkg/common/component"

type Component struct {
	component.DefaultComponent
}

func ID() string {
	return "s-rabbitmq"
}

func (redisc *Component) ID() string {
	return ID()
}

func (redisc *Component) Create(instConfig *component.ComponentConfig) (interface{}, error) {
	return NewMQ(instConfig.Name, instConfig.Config)
}

func (redisc *Component) Update(inst interface{}, instConfig *component.ComponentConfig) (interface{}, error) {
	r := inst.(*MQ)
	config := r.ParseConfig(instConfig.Config)
	newInst, err := r.UpdatePool(instConfig.Name, config)
	return newInst, err
}

func (redisc *Component) Destroy(inst interface{}) error {
	r := inst.(*MQ)
	return r.Destroy()
}
